// AUTO GENERATED CODE!
// CODE GENERATOR WILL NOT PRESERVE MANUAL CHANGES TO THIS CODE!
// 

// MIT License (MIT)
// 
// Copyright (c) 2014 K Ercan Turkarslan
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// 


using System;

namespace Mios.Generated.ServiceFiles
{
    // Generated from S_FanSpeed1.xml
    
    public class FanSpeed1Service : MiosService
    {
        #region FanSpeedTarget : Byte;
        private Byte? _mFanSpeedTarget;
        
        public Byte FanSpeedTarget
        {
            get
            {
                return _mFanSpeedTarget ?? GetFanSpeedTarget();
            }
        }
        
        #region Action SetFanSpeed(Byte newFanSpeedTarget) : String;
        public String SetFanSpeed(Byte newFanSpeedTarget)
        {
            if(newFanSpeedTarget > 100)
                throw new ArgumentOutOfRangeException("newFanSpeedTarget");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetFanSpeed",
                String.Format("NewFanSpeedTarget={0}", ToLuup(_mFanSpeedTarget = newFanSpeedTarget)));
        }
        #endregion Action SetFanSpeed
        
        #region Action GetFanSpeedTarget() : Byte;
        public Byte GetFanSpeedTarget()
        {
            _mFanSpeedTarget = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "FanSpeedTarget"));
            
            return _mFanSpeedTarget.Value;
        }
        #endregion Action GetFanSpeedTarget
        
        #endregion
        
        #region FanSpeedStatus : Byte;
        private Byte? _mFanSpeedStatus;
        
        public Byte FanSpeedStatus
        {
            get
            {
                return _mFanSpeedStatus ?? GetFanSpeed();
            }
        }
        
        #region Action SetFanSpeedStatus(Byte newFanSpeedStatus) : String;
        public String SetFanSpeedStatus(Byte newFanSpeedStatus)
        {
            if(newFanSpeedStatus > 100)
                throw new ArgumentOutOfRangeException("newFanSpeedStatus");
            
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetFanSpeedStatus",
                String.Format("newFanSpeedStatus={0}", ToLuup(_mFanSpeedStatus = newFanSpeedStatus)));
        }
        #endregion Action SetFanSpeedStatus
        
        #region Action GetFanSpeed() : Byte;
        public Byte GetFanSpeed()
        {
            _mFanSpeedStatus = FromLuupByte(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "FanSpeedStatus"));
            
            return _mFanSpeedStatus.Value;
        }
        #endregion Action GetFanSpeed
        
        #endregion
        
        #region DirectionTarget : Boolean;
        private Boolean? _mDirectionTarget;
        
        public Boolean DirectionTarget
        {
            get
            {
                return _mDirectionTarget ?? GetFanDirectionTarget();
            }
        }
        
        #region Action SetFanDirection(Boolean newDirectionTarget) : String;
        public String SetFanDirection(Boolean newDirectionTarget)
        {
            return Engine.Luup_CallAction(base.DeviceId, base.ServiceId, "SetFanDirection",
                String.Format("NewDirectionTarget={0}", ToLuup(_mDirectionTarget = newDirectionTarget)));
        }
        #endregion Action SetFanDirection
        
        #region Action GetFanDirectionTarget() : Boolean;
        public Boolean GetFanDirectionTarget()
        {
            _mDirectionTarget = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "DirectionTarget"));
            
            return _mDirectionTarget.Value;
        }
        #endregion Action GetFanDirectionTarget
        
        #endregion
        
        #region DirectionStatus : Boolean;
        private Boolean? _mDirectionStatus;
        
        public Boolean DirectionStatus
        {
            get
            {
                return _mDirectionStatus ?? GetFanDirection();
            }
        }
        
        #region Action GetFanDirection() : Boolean;
        public Boolean GetFanDirection()
        {
            _mDirectionStatus = FromLuupBoolean(Engine.Luup_VariableGet(base.DeviceId, base.ServiceId, "DirectionStatus"));
            
            return _mDirectionStatus.Value;
        }
        #endregion Action GetFanDirection
        
        #endregion
        
        
        #region Method SetVariable(String name, String value) : Boolean;
        internal override Boolean SetVariable(String name, String value)
        {
            switch(name)
            {
                case "DirectionStatus":
                    _mDirectionStatus = FromLuupBoolean(value); return true;
                case "DirectionTarget":
                    _mDirectionTarget = FromLuupBoolean(value); return true;
                case "FanSpeedStatus":
                    _mFanSpeedStatus = FromLuupByte(value); return true;
                case "FanSpeedTarget":
                    _mFanSpeedTarget = FromLuupByte(value); return true;
                default:
                    return false;
            }
        }
        #endregion Method SetVariable
        
        public FanSpeed1Service(MiosEngine engine, UInt32 deviceId, String serviceId)
            : base(engine, deviceId, serviceId)
        {
            
        } //End Constructor
    } //End of class
} //End of Namespace

